using System.Collections.Generic;
using System.Linq;

namespace ZerAx.Tweaks
{
    public static class EnumerableExtensions
    {
        /// <summary>
        /// Turn a Enumerable into a dictionary
        /// </summary>
        /// <typeparam name="K">The key</typeparam>
        /// <typeparam name="V">The value</typeparam>
        /// <param name="e">The enumerable</param>
        /// <returns></returns>
        public static Dictionary<K, V> ToDict<K, V>(this IEnumerable<(K, V)> e)
        {
            return new Dictionary<K, V>(e.Select(x => new KeyValuePair<K, V>(x.Item1, x.Item2)));
        }

        public static IEnumerable<T> ToEnumerable<T>(this T v)
        {
            yield return v;
        }
    }
}
